package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.RepositoryInfo;
import com.ruoyi.service.IRepositoryInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/webshop/repositoryInfo")
public class RepositoryInfoController extends BaseController
{
    @Autowired
    private IRepositoryInfoService repositoryInfoService;

    /**
     * 获取岗位列表
     */

    @GetMapping("/list")
    public TableDataInfo list(RepositoryInfo repositoryInfo)
    {
        System.out.println("repositoryInfo = " + repositoryInfo);
        startPage();
        List<RepositoryInfo> list = repositoryInfoService.selectRepositoryInfoList(repositoryInfo);
        return getDataTable(list);
    }




    @GetMapping(value = "/{repositoryId}")
    public AjaxResult getInfo(@PathVariable Long repositoryId)
    {
        return success(repositoryInfoService.selectRepositoryInfoById(repositoryId));
    }

    /**
     * 新增岗位
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody RepositoryInfo repositoryInfo)
    {

        return toAjax(repositoryInfoService.insertRepositoryInfo(repositoryInfo));
    }


    @PutMapping
    public AjaxResult edit(@Validated @RequestBody RepositoryInfo repositoryInfo)
    {

        return toAjax(repositoryInfoService.updateRepositoryInfo(repositoryInfo));
    }


    @DeleteMapping("/{repositoryIds}")
    public AjaxResult remove(@PathVariable Long[] repositoryIds)
    {
        return toAjax(repositoryInfoService.deleteRepositoryInfoByIds(repositoryIds));
    }


}
